home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
TIMELINE.DIR
/
00014_Script_SCROLLBAR SCRIPTS
< prev
next >
Wrap
Text File
|
1996-03-31
|
4KB
|
124 lines
on initScrollBar
global scrollBar,numOfPixelsPerScreen, halfNumPixelsPerScreen,thumb,timeLine,screenWidth
global numberOfScreens,firstTimeScreenframe, framesBetweenScreens
set scrollBar = 37 -- TimeBar
set thumb = 35
set firstTimeScreenframe = 19
set framesBetweenScreens = 2
set numberOfScreens = 19
puppetSprite thumb,1
-- the thumb has to be moved numOfPixelsPerScreen pixels to move the timeLine 1 screen
set scrollBarWidth = the width of sprite scrollBar
set numOfPixelsPerScreen = (scrollBarWidth * 1.0) / (numberOfScreens - 1)
set halfNumPixelsPerScreen = numOfPixelsPerScreen/2
-- restrict movement of thumb to the scrollbar
set the constraint of sprite thumb to scrollBar
set the moveableSprite of sprite thumb = TRUE
end
-------------------------------------------------------------------------------------
-- handler newScreen gets called when clicking on the scrollbar.
on newScreen
global thumb,screenWidth
repeat while the mouseDown
scroll
end repeat
end
-------------------------------------------------------------------------------------
-- handler newScreenBeforeFirstScreen gets called when clicking on the scrollbar.
-- before the first screen (this is necessary because otherwise the transition doesn't
-- work right).
on newScreenFromBeforeFirstScreen
global firstTimeScreenframe
go firstTimeScreenframe
newScreen
end
-------------------------------------------------------------------------------------
-- handler scrollFromBeforeFirstScreen gets called when dragging the thumb before
-- the first screen (this is necessary because otherwise the transition doesn't
-- work right).
on scrollFromBeforeFirstScreen
global firstTimeScreenframe
go firstTimeScreenframe
scroll
end
-------------------------------------------------------------------------------------
-- handler scroll gets called when dragging the thumb
on scroll
global thumb,scrollBar
repeat while the mouseDown
set newLocH = the mouseH
updateLocHOfItem thumb, newLocH
end repeat
updateTimeLine
end
-------------------------------------------------------------------------------------
-- handler updateTimeLine
-- calculates the new timeline screen from the position of the tumb.
-- shows the new timeline screen
-- calculates the thumbposition that corresponds with the new timeline screen
-- snaps the tumb into this new position
on updateTimeLine
global thumb, framesBetweenScreens, firstTimeScreenframe
set newScreen = getScreenNumFromThumbPos()
set newFrame = firstTimeScreenframe + (newScreen - 1) * framesBetweenScreens
if newFrame > the frame then
goForwardIntime newFrame
else if newFrame < the frame then
goBackIntime newFrame
end if
-- snap thumb to position
set newThumbPos = getThumbPosFromScreenNum(newScreen)
updateLocHOfItem thumb,newThumbPos
end
on getScreenNumFromThumbPos
global thumb,numOfPixelsPerScreen,halfNumPixelsPerScreen, scrollBar, numberOfScreens
set thumbPos = the locH of sprite thumb - the left of sprite scrollBar
-- set screenNum = integer((thumbPos+halfNumPixelsPerScreen) / numOfPixelsPerScreen)
set screenNum = integer(thumbPos / numOfPixelsPerScreen) + 1
if screenNum < 1 then set screenNum = 1
if screenNum > numberOfScreens then set screenNum = numberOfScreens
return screenNum
end
on getThumbPosFromScreenNum aScreen
global numOfPixelsPerScreen,scrollBar
set newLocH = the left of sprite scrollBar + integer((aScreen-1) * numOfPixelsPerScreen)
return newLocH
end
on updateLocHOfItem aSprite, aLocH
set the locH of sprite aSprite to aLocH
updateStage
end